import java.util.Optional;

/**
 * @author understand
 * @description:
 * @create 2025/5/23 16:43
 */
public class OptionalTest {
    //1.Optional的 使用 防止空指针异常
    public static void main(String[] args) {
        System.out.println(sum(null, null));
    }
    public static Integer sum(Integer a, Integer b) {
        //1.赋值
        Optional<Integer> d = Optional.of(10);
        Optional<Integer> e = Optional.ofNullable(20);
        System.out.println("zdfvxc： "+e.toString());
        ;
        //2.取值
        Integer c = d.get() ;
        c=d.orElse(0);
        a=10;
        return Optional.ofNullable(a).orElse(0) + Optional.ofNullable(b).orElse(0);
    }
}
